#!/bin/bash
# Generate a list of target values to be "guessed"
(cd base-files && ./php8.0 get_target_values.php > ../exploit/target_values.txt)

# Place the target values in a PHP file test the exploit and
#   place the PID and Epoch time in the exploit file
python3 setup_test.py

# Compile the exploit
echo "Compiling exploit..."
gcc exploit/exploit.c -o exploit/exploit

# Generate a list of PHP seeds to test
echo "Generating seeds..."
./exploit/exploit > exploit/seeds.lst

# Remove duplicate seeds from the generated list to save time
echo "Removing Duplicates..."
sort exploit/seeds.lst | uniq > exploit/seeds_nodup.lst

# Test the exploit
echo "Testing exploit..."
(cd exploit && ./php8.0 test_exploit.php)
